package org.server.common;

import com.iohao.game.action.skeleton.core.CmdInfo;
import com.iohao.game.action.skeleton.core.commumication.BroadcastContext;
import com.iohao.game.bolt.broker.core.client.BrokerClientHelper;
import org.server.domain.Result.Msg;

import java.util.Collection;
import java.util.List;

public class BroadcastUtils {
    public static BroadcastContext broadcastContext = BrokerClientHelper.me().getBroadcastContext();
    /**
     * 给群组发送消息
     * @param cmd
     * @param subCmd
     * @param msg
     * @param userIds
     * @return void
     * @author Tang
     * @date 2023/4/18 15:26
    **/
    public static void broadcast(int cmd, int subCmd, Msg msg, Collection<Long> userIds) {
        CmdInfo cmdInfo = CmdInfo.getCmdInfo(cmd, subCmd);
        broadcastContext.broadcast(cmdInfo, msg, userIds);
    }
    /**
     * 单点发送消息
     * @param cmd
     * @param subCmd
     * @param msg
     * @param userId
     * @return void
     * @author Tang
     * @date 2023/4/18 15:26
    **/
    public static void broadcast(int cmd, int subCmd, Msg msg, Long userId) {
        CmdInfo cmdInfo = CmdInfo.getCmdInfo(cmd, subCmd);
        broadcastContext.broadcast(cmdInfo, msg, userId);
    }
}
